﻿using System;
using System.Collections.Generic;
using JTLeigh.Commerce.Spencer.Core.Service.Contracts;
using JTLeigh.Commerce.Spencer.Core.Testing;
using JTLeigh.Commerce.Spencer.Features.ProductImages.Service.Contracts.Runtime.GetProductImages;
using JTLeigh.Commerce.Spencer.Features.ProductImages.Service.Contracts.Runtime.GetProductImageSnapshot;
using JTLeigh.Commerce.Spencer.Features.ProductImages.Service.Contracts.Runtime.GetProductImageSummaries;
using JTLeigh.Commerce.Spencer.IntegrationTests.ProductImagesRuntimeService;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GetProductImages_ProductImageSize = JTLeigh.Commerce.Spencer.Features.ProductImages.Service.Contracts.Runtime.GetProductImages.ProductImageSize;

namespace JTLeigh.Commerce.Spencer.IntegrationTests
{

    /// <summary>
    /// Integration tests for the Product Images service.
    /// </summary>
    /// <remarks>
    /// <para>
    /// These test cases depend on data in the ProductImageMetadata and ProductImage
    /// databases.
    /// </para>
    /// </remarks>
    [TestClass]
	public class ProductImagesRuntimeServiceFixture
	{

		#region Inner Classes and Methods

		private static class Constants
		{

			public static class ProductImageView
			{

				public static class ViewId
				{
					public static readonly Guid Default = new Guid("6FA58DE8-E1C0-4d7c-B720-267498C24EC4");
					public static readonly Guid Front = new Guid("32583D4F-673D-4a7b-BDEA-4FA444264B92");
					public static readonly Guid Left = new Guid("8A282AC2-195A-4962-87EE-318960F731A2");
					public static readonly Guid Right = new Guid("33C67D3D-7DDF-46b8-A5BA-B669CE1382D9");
					public static readonly Guid Top = new Guid("9EE55995-C7D1-4cf7-95C8-E9AE593F8F33");
					public static readonly Guid Bottom = new Guid("BEDA5C2A-C6B0-4716-AF50-FCD05AD61725");
					public static readonly Guid Back = new Guid("944E17C5-1B86-4b96-9ADC-F3FA6CB6316B");
				}

				public static class WellKnownViewCode
				{
					public const byte Default = 1;
					public const byte Front = 2;
					public const byte Left = 3;
					public const byte Right = 4;
					public const byte Top = 5;
					public const byte Bottom = 6;
					public const byte Back = 7;
				}

			}

			public static class ProductImageSize
			{

				public static class SizeId
				{
					public static readonly Guid Thumbnail = new Guid("176CE418-6309-4d9f-928C-8CFE344D40A8");
					public static readonly Guid Small = new Guid("E60FF2A3-3EC7-44d6-913F-4FB6BD9FDDE1");
					public static readonly Guid Medium = new Guid("2B22C915-C251-4345-99CC-20B511C19297");
					public static readonly Guid Large = new Guid("F675D9B1-AE08-4c63-A84B-F8BE0B370E9B");
				}

				public static class WellKnownSizeCode
				{
					public const byte Thumbnail = 1;
					public const byte Small = 2;
					public const byte Medium = 3;
					public const byte Large = 4;
				}

			}

		}

		#endregion // Inner Classes and Methods

		#region Methods

        /// <summary>
        /// FIXME
        /// </summary>
		[TestMethod]
		public void TestGetProductImagesEnglish()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImagesRequest request;
			GetProductImagesResponse response;
			ProductImage image;
			ProductImageView view;
			GetProductImages_ProductImageSize size;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImagesRequest
                {
                    ProductId = new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
                        ProductId = "123",
                    },
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.EnglishCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImages(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImagesResponse(response);

			// ensure all images came across

			Assert.AreEqual(4, response.Images.Count);

			// ensure each image has the correct values

			Assert.IsTrue(response.Images.TryGetValue(new Guid("F12E8901-E609-4db6-A358-3DEAC60ACDF3"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Default, image.ViewId); // Default
			Assert.AreEqual("123 Default View", image.AlternativeText);
			Assert.IsNull(image.UsagePermissionText);
			Assert.AreEqual(4, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Thumbnail)); // Thumbnail
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Medium)); // Medium
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Large)); // Large

			Assert.IsTrue(response.Images.TryGetValue(new Guid("E48A802B-7937-47a4-8D8A-4848D7FC0A18"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Front, image.ViewId); // Front
			Assert.AreEqual("123 Front View", image.AlternativeText);
			Assert.IsNull(image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			Assert.IsTrue(response.Images.TryGetValue(new Guid("3345A027-6E4D-43ae-8223-A8ADE5A2EC29"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Left, image.ViewId); // Left
			Assert.AreEqual("123 Left View", image.AlternativeText);
			Assert.IsNull(image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			Assert.IsTrue(response.Images.TryGetValue(new Guid("46190C17-5985-4afd-8C6F-9BCA11BDD948"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Right, image.ViewId); // Right
			Assert.AreEqual("123 Right View", image.AlternativeText);
			Assert.IsNull(image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			// ensure all views came across

			Assert.AreEqual(4, response.Views.Count);

			// ensure each view has the correct values

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Default, out view)); // Default
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Default, view.WellKnownViewCode);
			Assert.AreEqual(1, view.DisplayOrder);
			Assert.AreEqual("Default", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Front, out view)); // Front	
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Front, view.WellKnownViewCode);
			Assert.AreEqual(2, view.DisplayOrder);
			Assert.AreEqual("Front", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Left, out view)); // Left
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Left, view.WellKnownViewCode);
			Assert.AreEqual(3, view.DisplayOrder);
			Assert.AreEqual("Left", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Right, out view)); // Right
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Right, view.WellKnownViewCode);
			Assert.AreEqual(4, view.DisplayOrder);
			Assert.AreEqual("Right", view.Name);

			// ensure all sizes came across

			Assert.AreEqual(4, response.Sizes.Count);

			// ensure each size has the correct values

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Thumbnail, out size)); // Thumbnail
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Thumbnail, size.WellKnownSizeCode);
			Assert.AreEqual(25, size.Width);
			Assert.AreEqual(25, size.Height);
			Assert.AreEqual(1, size.DisplayOrder);
			Assert.AreEqual("Thumbnail", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Small, out size)); // Small
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Small, size.WellKnownSizeCode);
			Assert.AreEqual(75, size.Width);
			Assert.AreEqual(75, size.Height);
			Assert.AreEqual(2, size.DisplayOrder);
			Assert.AreEqual("Small", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Medium, out size)); // Medium
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Medium, size.WellKnownSizeCode);
			Assert.AreEqual(150, size.Width);
			Assert.AreEqual(150, size.Height);
			Assert.AreEqual(3, size.DisplayOrder);
			Assert.AreEqual("Medium", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Large, out size)); // Large
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Large, size.WellKnownSizeCode);
			Assert.AreEqual(300, size.Width);
			Assert.AreEqual(300, size.Height);
			Assert.AreEqual(4, size.DisplayOrder);
			Assert.AreEqual("Large", size.Name);

		}

        /// <summary>
        /// FIXME
        /// </summary>
		[TestMethod]
		public void TestGetProductImagesFrench()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImagesRequest request;
			GetProductImagesResponse response;
			ProductImage image;
			ProductImageView view;
			GetProductImages_ProductImageSize size;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImagesRequest
                {
                    ProductId = new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
                        ProductId = "456",
                    },
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.FrenchCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImages(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImagesResponse(response);

			// ensure all images came across

			Assert.AreEqual(5, response.Images.Count);

			// ensure each image has the correct values

			Assert.IsTrue(response.Images.TryGetValue(new Guid("C3C7CE37-3CFB-481f-840B-BC36F0B8BBA3"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Default, image.ViewId); // Default
			Assert.AreEqual("456 Vue de défaut", image.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", image.UsagePermissionText);
			Assert.AreEqual(4, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Thumbnail)); // Thumbnail
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Medium)); // Medium
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Large)); // Large

			Assert.IsTrue(response.Images.TryGetValue(new Guid("2B6C7F92-9150-443d-A162-B5AE39F8E438"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Front, image.ViewId); // Front
			Assert.AreEqual("456 Vue de face", image.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			Assert.IsTrue(response.Images.TryGetValue(new Guid("D08811F6-E73C-4bcc-BDD5-7261175E9711"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Top, image.ViewId); // Top
			Assert.AreEqual("456 Vue de dessus", image.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			Assert.IsTrue(response.Images.TryGetValue(new Guid("D0947ABA-D7BA-4031-B5AF-B08FC0B84416"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Bottom, image.ViewId); // Bottom
			Assert.AreEqual("456 Vue de fond", image.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			Assert.IsTrue(response.Images.TryGetValue(new Guid("9089CFE3-75C4-44db-B485-013B16FC7EE6"), out image));
			Assert.AreEqual(Constants.ProductImageView.ViewId.Back, image.ViewId); // Back
			Assert.AreEqual("456 Vue de dos", image.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", image.UsagePermissionText);
			Assert.AreEqual(1, image.Variants.Count);
			Assert.IsTrue(image.Variants.ContainsKey(Constants.ProductImageSize.SizeId.Small)); // Small

			// ensure all views came across

			Assert.AreEqual(5, response.Views.Count);

			// ensure each view has the correct values

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Default, out view)); // Default
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Default, view.WellKnownViewCode);
			Assert.AreEqual(1, view.DisplayOrder);
			Assert.AreEqual("Standard", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Front, out view)); // Front	
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Front, view.WellKnownViewCode);
			Assert.AreEqual(2, view.DisplayOrder);
			Assert.AreEqual("Avant", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Top, out view)); // Top
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Top, view.WellKnownViewCode);
			Assert.AreEqual(5, view.DisplayOrder);
			Assert.AreEqual("Dessus", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Bottom, out view)); // Bottom
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Bottom, view.WellKnownViewCode);
			Assert.AreEqual(6, view.DisplayOrder);
			Assert.AreEqual("Fond", view.Name);

			Assert.IsTrue(response.Views.TryGetValue(Constants.ProductImageView.ViewId.Back, out view)); // Back
			Assert.AreEqual(Constants.ProductImageView.WellKnownViewCode.Back, view.WellKnownViewCode);
			Assert.AreEqual(7, view.DisplayOrder);
			Assert.AreEqual("Dos", view.Name);

			// ensure all sizes came across

			Assert.AreEqual(4, response.Sizes.Count);

			// ensure each size has the correct values

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Thumbnail, out size)); // Thumbnail
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Thumbnail, size.WellKnownSizeCode);
			Assert.AreEqual(25, size.Width);
			Assert.AreEqual(25, size.Height);
			Assert.AreEqual(1, size.DisplayOrder);
			Assert.AreEqual("Minuscule", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Small, out size)); // Small
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Small, size.WellKnownSizeCode);
			Assert.AreEqual(75, size.Width);
			Assert.AreEqual(75, size.Height);
			Assert.AreEqual(2, size.DisplayOrder);
			Assert.AreEqual("Petit", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Medium, out size)); // Medium
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Medium, size.WellKnownSizeCode);
			Assert.AreEqual(150, size.Width);
			Assert.AreEqual(150, size.Height);
			Assert.AreEqual(3, size.DisplayOrder);
			Assert.AreEqual("Moyen", size.Name);

			Assert.IsTrue(response.Sizes.TryGetValue(Constants.ProductImageSize.SizeId.Large, out size)); // Large
			Assert.AreEqual(Constants.ProductImageSize.WellKnownSizeCode.Large, size.WellKnownSizeCode);
			Assert.AreEqual(300, size.Width);
			Assert.AreEqual(300, size.Height);
			Assert.AreEqual(4, size.DisplayOrder);
			Assert.AreEqual("Grand", size.Name);

		}

        /// <summary>
        /// FIXME
        /// </summary>
		[TestMethod]
		public void TestGetProductImageSnapshotEnglish()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImageSnapshotRequest request;
			GetProductImageSnapshotResponse response;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImageSnapshotRequest
                {
                    ProductId = new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
                        ProductId = "123",
                    },
                    WellKnownViewCode = Constants.ProductImageView.WellKnownViewCode.Default,
                    WellKnownSizeCode = Constants.ProductImageSize.WellKnownSizeCode.Small,
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.EnglishCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImageSnapshot(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImageSnapshotResponse(response);

			// ensure the snapshot has the correct values

			Assert.AreEqual("123 Default View", response.Snapshot.AlternativeText);
			Assert.IsNull(response.Snapshot.UsagePermissionText);
			Assert.AreEqual(75, response.Snapshot.Width);
			Assert.AreEqual(75, response.Snapshot.Height);
			Assert.AreEqual("123-default-view-small.gif", response.Snapshot.Path);
			Assert.AreEqual(3, response.Snapshot.OtherSizes); // Thumbnail, Medium, Large
			Assert.AreEqual(3, response.Snapshot.OtherImages); // Front, Left, Right

		}

        /// <summary>
        /// FIXME
        /// </summary>
		[TestMethod]
		public void TestGetProductImageSnapshotFrench()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImageSnapshotRequest request;
			GetProductImageSnapshotResponse response;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImageSnapshotRequest
                {
                    ProductId = new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
                        ProductId = "456",
                    },
                    WellKnownViewCode = Constants.ProductImageView.WellKnownViewCode.Default,
                    WellKnownSizeCode = Constants.ProductImageSize.WellKnownSizeCode.Small,
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.FrenchCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImageSnapshot(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImageSnapshotResponse(response);

			// ensure the snapshot has the correct values

			Assert.AreEqual("456 Vue de défaut", response.Snapshot.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", response.Snapshot.UsagePermissionText);
			Assert.AreEqual(75, response.Snapshot.Width);
			Assert.AreEqual(75, response.Snapshot.Height);
			Assert.AreEqual("456-default-view-small.gif", response.Snapshot.Path);
			Assert.AreEqual(3, response.Snapshot.OtherSizes); // Thumbnail, Medium, Large
			Assert.AreEqual(4, response.Snapshot.OtherImages); // Front, Top, Bottom, Back

		}

        /// <summary>
        /// FIXME
        /// </summary>
        [TestMethod]
		public void TestGetProductImageSummariesEnglish()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImageSummariesRequest request;
			GetProductImageSummariesResponse response;
			ProductImageSummary summary;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImageSummariesRequest
                {
                    ProductIds = new List<FullyQualifiedProductId>
				{
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
					    ProductId = "123",
                    },
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
					    ProductId = "456",
                    },
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
					    ProductId = "789",
                    },
				},
                    WellKnownViewCode = Constants.ProductImageView.WellKnownViewCode.Default,
                    WellKnownSizeCode = Constants.ProductImageSize.WellKnownSizeCode.Small,
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.EnglishCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImageSummaries(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImageSummariesResponse(response);

			// ensure the size has the correct values

			Assert.AreEqual(75, response.Size.Width);
			Assert.AreEqual(75, response.Size.Height);

			// ensure each summary has the correct values

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "123" }, out summary));
			Assert.AreEqual("123 Default View", summary.AlternativeText);
			Assert.IsNull(summary.UsagePermissionText);
			Assert.AreEqual("123-default-view-small.gif", summary.Path);

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "456" }, out summary));
			Assert.AreEqual("456 Default View", summary.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. All rights reserved.", summary.UsagePermissionText);
			Assert.AreEqual("456-default-view-small.gif", summary.Path);

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "789" }, out summary));
			Assert.IsNull(summary.AlternativeText);
			Assert.IsNull(summary.UsagePermissionText);
			Assert.AreEqual(@"en-CA\missing-image-small.gif", summary.Path);

		}

        /// <summary>
        /// FIXME
        /// </summary>
        [TestMethod]
		public void TestGetProductImageSummariesFrench()
		{
			ProductImagesRuntimeServiceClient client;
			GetProductImageSummariesRequest request;
			GetProductImageSummariesResponse response;
			ProductImageSummary summary;

            using (client = new ProductImagesRuntimeServiceClient())
            {

                request = new GetProductImageSummariesRequest
                {
                    ProductIds = new List<FullyQualifiedProductId>
				{
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
    					ProductId = "123",
                    },
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
					    ProductId = "456",
                    },
                    new FullyQualifiedProductId
                    {
                        CatalogId = "BaseCatalog",
					    ProductId = "789",
                    },
				},
                    WellKnownViewCode = Constants.ProductImageView.WellKnownViewCode.Default,
                    WellKnownSizeCode = Constants.ProductImageSize.WellKnownSizeCode.Small,
                    TenantId = TestConstants.TenantId.JTLeigh,
                    CultureId = TestConstants.CultureId.FrenchCanada,
                    EffectiveDate = new DateTime(2008, 06, 01)
                };

                response = client.GetProductImageSummaries(request);

                client.Close();
            }

			// validate the response

			ValidateGetProductImageSummariesResponse(response);

			// ensure the size has the correct values

			Assert.AreEqual(75, response.Size.Width);
			Assert.AreEqual(75, response.Size.Height);

			// ensure the 

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "123" }, out summary));
			Assert.AreEqual("123 Vue de défaut", summary.AlternativeText);
			Assert.IsNull(summary.UsagePermissionText);
			Assert.AreEqual("123-default-view-small.gif", summary.Path);

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "456" }, out summary));
			Assert.AreEqual("456 Vue de défaut", summary.AlternativeText);
			Assert.AreEqual("Copyright 2008 456 Corporation Ltd. Tous droits réservés.", summary.UsagePermissionText);
			Assert.AreEqual("456-default-view-small.gif", summary.Path);

            Assert.IsTrue(response.Summaries.TryGetValue(new FullyQualifiedProductId { CatalogId = "BaseCatalog", ProductId = "789" }, out summary));
			Assert.IsNull(summary.AlternativeText);
			Assert.IsNull(summary.UsagePermissionText);
			Assert.AreEqual(@"fr-CA\missing-image-small.gif", summary.Path);

		}

		#endregion // Methods

		#region Implementation

		private static void ValidateGetProductImagesResponse(GetProductImagesResponse response)
		{

			// all collections must not be null
			Assert.IsNotNull(response);
			Assert.IsNotNull(response.Images);
			Assert.IsNotNull(response.Views);
			Assert.IsNotNull(response.Sizes);

			foreach (ProductImage image in response.Images.Values)
			{

				// all sub-collections must not be null
				Assert.IsNotNull(image.Variants);

				// all views referred to by images must appear in the views collection
				Assert.IsTrue(response.Views.ContainsKey(image.ViewId));

				foreach (ProductImageVariant variant in image.Variants.Values)
				{

					// all sizes referred to by variants must appear in the sizes collection
					Assert.IsTrue(response.Sizes.ContainsKey(variant.SizeId));

				}

			}

		}

		private static void ValidateGetProductImageSnapshotResponse(GetProductImageSnapshotResponse response)
		{

			// all collections must not be null
			Assert.IsNotNull(response);
			Assert.IsNotNull(response.Snapshot);

		}

		private static void ValidateGetProductImageSummariesResponse(GetProductImageSummariesResponse response)
		{

			// all collections must not be null
			Assert.IsNotNull(response);
			Assert.IsNotNull(response.Size);
			Assert.IsNotNull(response.Summaries);

		}

		#endregion // Implementation

	}

}
